package com.ythook.mentor.service;

import com.ythook.mentor.entity.Technologies;
import com.ythook.mentor.repository.TechnologiesRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.List;
import java.util.Optional;

@Service
@Transactional
public class TechnologiesService {
    @Resource
    private TechnologiesRepository technologiesRepository;

    public List<Technologies> search() {
        return technologiesRepository.findAll();
    }

    public Optional<Technologies> findById(Long id) {
        return technologiesRepository.findById(id);
    }
    public List<Technologies> findByName(String name) {
        return technologiesRepository.findByName(name);
    }
    public void delete(Long id) {
        technologiesRepository.deleteById(id);
    }

    public Technologies add(Technologies technologies) {
        return technologiesRepository.save(technologies);
    }
    public Technologies update(Technologies technologies) {
            return technologiesRepository.save(technologies);
    }
}
